<template>
    <div class="sidebar">
        <el-menu
            class="sidebar-el-menu"
            :default-active="onRoutes"
            :collapse="true"
            background-color="white"
            text-color="black"
            active-text-color="#20a0ff"
            unique-opened
            router
        >
            <template v-for="item in items">
                <template>    
                    <el-menu-item :index="item.index" :key="item.index">
                        <i :class="item.icon" style="color: #409EFF;"></i>
                        <span slot="title">{{ item.title }}</span>
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
export default {
    data() {
        return {
            items: [
                {
                    icon: 'el-icon-s-home',
                    index: 'userCenter',
                    title: '个人中心'
                },
                {
                    icon: 'el-icon-date',
                    index: 'historyRegister',
                    title: '历史登记信息'
                },
                {
                    icon: 'el-icon-edit',
                    index: 'register',
                    title: '健康信息登记'
                },
            ]
        };
    },
    computed: {
        onRoutes() {
            return this.$route.path.replace('/', '');
        }
    }
};
</script>

<style scoped>
.sidebar {
    display: block;
    position: absolute;
    left: 0;
    top: 70px;
    bottom: 0;
    overflow-y: scroll;
}
.sidebar::-webkit-scrollbar {
    width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
    /* width: 250px; */
    width: 65px;
    /* background-color: #409EFF; */
}
.sidebar > ul {
    height: 100%;
}
</style>